package com.github.fashionbrot.util;

import com.github.fashionbrot.annotation.Permission;
import com.github.fashionbrot.exception.TokenExpiredException;
import com.github.fashionbrot.function.*;
import org.omg.CORBA.PUBLIC_MEMBER;

import java.lang.reflect.Method;
import java.util.Set;
import java.util.function.BiPredicate;
import java.util.function.Predicate;

public class PermissionUtil {



    public static boolean checkPermission(Method method, Predicate<String[]> verify) {
        if (method==null){
            return false;
        }
        GetAnnotationFunction annotationFunction = annotationMethod -> {
            if (annotationMethod.getAnnotation(Permission.class) == null) {
                return null;
            }
            return annotationMethod.getAnnotation(Permission.class).value();
        };

        return verify.test(annotationFunction.value(method));
    }



}
